<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>KoldarCTester: Koldar C Tester: a simple C tester</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">KoldarCTester
   &#160;<span id="projectnumber">1.2</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('index.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Koldar C Tester: a simple C tester </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#section08">Contacts</a></li>
<li class="level1"><a href="#section01">Introduction</a></li>
<li class="level1"><a href="#section02">To All People who want to setup it quickly</a></li>
<li class="level1"><a href="#section11">Koldar C Tester Compressed version</a></li>
<li class="level1"><a href="#section03">How to use KoldarCTester</a></li>
<li class="level1"><a href="#section04">Basic Elements in the header</a></li>
<li class="level1"><a href="#section05">Assertion</a></li>
<li class="level1"><a href="#section06">Skip tests</a></li>
<li class="level1"><a href="#section07">Deeper understanding of KoldarCTester.h</a></li>
<li class="level1"><a href="#section09">Name Conventions</a></li>
<li class="level1"><a href="#section10">Writing you own assertions</a></li>
</ul>
</div>
<div class="textblock"><dl class="section date"><dt>Date</dt><dd>Nov 27, 2013 </dd></dl>
<dl class="section author"><dt>Author</dt><dd>koldar </dd></dl>
<dl class="section version"><dt>Version</dt><dd>1.2</dd></dl>
<h1><a class="anchor" id="section08"></a>
Contacts</h1>
<p>If you have suggestions or complaints you can email me sending a mail to <a href="#" onclick="location.href='mai'+'lto:'+'mas'+'si'+'mob'+'on'+'o1@'+'gm'+'ail'+'.c'+'om'; return false;">massi<span style="display: none;">.nosp@m.</span>mobo<span style="display: none;">.nosp@m.</span>no1@g<span style="display: none;">.nosp@m.</span>mail<span style="display: none;">.nosp@m.</span>.com</a>: i won't promise you that you'll receive a quick answer but I hope you understand!</p>
<h1><a class="anchor" id="section01"></a>
Introduction</h1>
<p>The KoldarCTester is a single header that can be used to quickly implement a test case for C code. C++ pure code is not supported though.</p>
<h1><a class="anchor" id="section02"></a>
To All People who want to setup it quickly</h1>
<p>If you're in a hurry and want to setup KoldarCTester now, copy and paste in your project <a class="el" href="KoldarCTester_8h.html">KoldarCTester.h</a>. Here the basic example to make it work:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="KoldarCTester_8h.html">KoldarCTester.h</a>&quot;</span></div>
<div class="line"></div>
<div class="line"><span class="comment">//All test function must have no formal parameters and void as return type</span></div>
<div class="line"><span class="keywordtype">void</span> testSomething(){</div>
<div class="line">        <span class="comment">//code something here</span></div>
<div class="line">        <span class="keywordflow">if</span> (a!=5){</div>
<div class="line">                failMsg(<span class="stringliteral">&quot;a is not 5!\n&quot;</span>);</div>
<div class="line">        }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> testSomethingElse(){</div>
<div class="line">        <span class="comment">//code something here</span></div>
<div class="line">        <span class="keywordflow">if</span> (a&gt;4){</div>
<div class="line">                fail();</div>
<div class="line">        }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(){</div>
<div class="line">        <a class="code" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57">kct_addTest</a>(testSomething);</div>
<div class="line">        <a class="code" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57">kct_addTest</a>(testSomethingElse);</div>
<div class="line"></div>
<div class="line">        kct_runAllTest(stdout);</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="section11"></a>
Koldar C Tester Compressed version</h1>
<p>Koldar C Tester is single header holding only macros: so you need no changes in your makefile. Still, all the documentation source is held inside the header as well. If you think you don't need this documentation (because you already have the html version) you can use the file called "KoldarCTesterCompressed.h". This file is exactly equal to "KoldarCTester.h" but it don't contain any comment line: in this way the file is large only about 500 lines. </p><dl class="section warning"><dt>Warning</dt><dd>I don't always update KoldarCTesterCompressed.h. If you feel your version is not updated you might consider to update it yourself. To do so you only have to run these command on your linux terminal: <pre class="fragment">*       cd utils
*       gcc -o removeComments removeComments.c
*       cd ..
*       cat macro/KoldarCTester.h | utils/removeComments &gt; macro/KoldarCTesterCompressed.h
*       </pre></dd></dl>
<h1><a class="anchor" id="section03"></a>
How to use KoldarCTester</h1>
<p>Now that all the guys in a hurry are satisfied we can discuss how to correctly use this header. To use it you have to copy "KoldarCTester.h" within your header paths. After that you can create a new .c files that will be used as a single test suite: if you want more test suites, you'll have to create more .c files. A single test file .c is divided into 2 parts: </p><ul>
<li>some test functions; </li>
<li>a main function;</li>
</ul>
<p>Basically KoldarCTester is a function list manager: you create some function and then you use some header function to add them in a list. After that you can execute them all in one command: the header handles all the work for you. So, first of all, you can create a new file (call it TestInteger.c for example) and include the header:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="KoldarCTester_8h.html">KoldarCTester.h</a>&quot;</span></div>
</div><!-- fragment --><p>You have to be sure the header is inside in your "include paths" (maybe through the -I compiler directive). Secondly you have to create some test functions. For example, I have created these:</p>
<div class="fragment"><div class="line"><span class="comment">//Create 100 random number between 0 and 9 and test whether or</span></div>
<div class="line"><span class="comment">//not the upper and lower bound are not violated.</span></div>
<div class="line"><span class="keywordtype">void</span> testRandomX(){</div>
<div class="line">        <span class="keywordtype">int</span> i;</div>
<div class="line">        <span class="keywordtype">int</span> n;</div>
<div class="line">        <span class="keywordflow">for</span> (i=0;i&lt;100;i++){</div>
<div class="line">                n=rand()%10;</div>
<div class="line">                <a class="code" href="KoldarCTester_8h.html#a0871daf80ad3af568bac7e0502c17205">kct_assertExtremis</a>(0,9,<span class="keyword">true</span>,<span class="keyword">true</span>,rand()%10);</div>
<div class="line">        }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">//Test if the power of 2 is greater than 0</span></div>
<div class="line"><span class="keywordtype">void</span> testPower(){</div>
<div class="line">        <span class="keywordtype">int</span> i;</div>
<div class="line">        <span class="keywordtype">int</span> num;</div>
<div class="line">        <span class="keywordflow">for</span> (i=0;i&lt;100;i++){</div>
<div class="line">                num=rand()%100;</div>
<div class="line">                <a class="code" href="KoldarCTester_8h.html#ab47b71b14664ccf62a03056bf6afd299">kct_assertCondition</a>(num*num&gt;=0);</div>
<div class="line">        }</div>
<div class="line">}</div>
</div><!-- fragment --><p>Let's skip up for the moment the "kct_assertExtremis" and "kct_assertCondition" part. Now you have created all the test you need to verify some feature of your program. Now you need to run these tests... how? The main function does exactly that:</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> main(){</div>
<div class="line">        <span class="comment">//add tests in the function list</span></div>
<div class="line">        <a class="code" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57">kct_addTest</a>(testRandomX);</div>
<div class="line">        <a class="code" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57">kct_addTest</a>(testPower);</div>
<div class="line">        <span class="comment">//run the tests</span></div>
<div class="line">        kct_runAllTest(stdout);</div>
<div class="line">}</div>
</div><!-- fragment --><p>Now you can build it. The compiler will probably complaints about "addTest" and "kct_runAllTest" do nothings: don't trust him, these function are actually pretty useful! Now try to run the program: you should get something like this:</p>
<div class="image">
<img src="image01.png" alt="image01.png"/>
</div>
<p>The tests are stored in a list: though it might be not so fast (like Bjame Stroudtrup say in <a href="http://www.youtube.com/watch?v=YQs6IC-vgmo">http://www.youtube.com/watch?v=YQs6IC-vgmo</a>), the list are quite easy to understand even for programmers beginner, so everyone can improve freely the header. Moreover, unlike other test suite, this header is totally <b>free of memory leak</b>. Sure, you can say: "well, that's should be obvious!"; well, of course it is, but you'll never know what you download out in the internet.</p>
<h1><a class="anchor" id="section04"></a>
Basic Elements in the header</h1>
<p>In the header there are basically 6 important elements:</p><ol type="1">
<li>assertions;</li>
<li>function <a class="el" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57" title="adds a new function in the test list ">kct_addTest()</a>;</li>
<li>function <a class="el" href="KoldarCTester_8h.html#a410bf9dc82153e2f88b61ea9e360ab40" title="run all the test added to the test list. ">kct_runAllTests()</a>;</li>
<li>variable currentTest;</li>
<li>variable testList;</li>
<li>control macros;</li>
</ol>
<p><a class="el" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57" title="adds a new function in the test list ">kct_addTest()</a> is the main function used to add a test function in the list. There is also a alternative version of this function called <a class="el" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e" title="adds a new function in the test list ">kct_addTestImproved()</a>: it has the same aim of <a class="el" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57" title="adds a new function in the test list ">kct_addTest()</a> but with this function you can also specify whether or not you want to skip the function.</p>
<p>kct_runAllTest() is obviously used to execute all the test the programmer coded. Note that with this function the list is automatically deallocated from the heap: in this way, if you are testing memory leak in your code, Koldar C Tester will not produces memory leaks by itself.</p>
<p>The assertions are the core of the testing: they allows you to check if a particular data satisfy a particular condition. See <a class="el" href="index.html#section05">Assertion</a> for more info.</p>
<p>The control macros are particular macros that allows you to tweak the parameters used by the header. This includes some constants like feel&amp;look strings and conversion buffer size.</p>
<p>"testList" variable represents the list that will store the test functions and some other data. See <a class="el" href="index.html#section07">Deeper understanding of KoldarCTester.h</a> for further information</p>
<p>"currentTest" is the test that is running at the moment; it is mainly used to lighten the prototype of the function: in this way the developer can <b>focus</b> on the test development insted of wasting time on understand the testing suite. Again, see <a class="el" href="index.html#section07">Deeper understanding of KoldarCTester.h</a> for additional data</p>
<h1><a class="anchor" id="section05"></a>
Assertion</h1>
<p>As we have introduce in the previous section, one of the most important things in the header are assertions. Assertions are shortcuts to test some conditions: if the condition is met nothing happens; otherwise the test is terminate and the header alerts you that in the specific test something went wrong.</p>
<p>For example, let assume you want to determinate if a pointer to a FILE returned by fopen is NULL or not. Normally you do something like this:</p>
<div class="fragment"><div class="line">FILE* f=fopen(<span class="stringliteral">&quot;../test/fileToParse.txt&quot;</span>,<span class="stringliteral">&quot;r&quot;</span>);</div>
<div class="line"><span class="keywordflow">if</span> (f==NULL){</div>
<div class="line">        fprintf(stderr,<span class="stringliteral">&quot;Cannot open the file!\n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">}</div>
</div><!-- fragment --><p>This works, but if you have lots of these small control your code readability can substantly decrease. Assert helps you in that:</p>
<div class="fragment"><div class="line">FILE* f=fopen(<span class="stringliteral">&quot;../test/fileToParse.txt&quot;</span>,<span class="stringliteral">&quot;r&quot;</span>);</div>
<div class="line">kct_assertNotNullMsg(<span class="stringliteral">&quot;cannot open the file!\n&quot;</span>,f);</div>
</div><!-- fragment --><p>Smaller and more readable, right? Koldar C Tester let you use a lot of these assertions: you can read about all of them in the documentation! Generally speaking, however, assertion are divided into 2 strains:</p>
<ul>
<li><b>pure assertions</b> check only a particular condition;</li>
<li><b>message assertion</b> check a particular condition and if it is not met they warn you with an error message</li>
</ul>
<h1><a class="anchor" id="section06"></a>
Skip tests</h1>
<p>Let assume you have 100 tests regarding a particular big feature of your program. It is probable that, to execute all 100 tests, your computer needs some time. If you are sure that some tests (i.e 53 and 67) return a OK status, you might want to skip them, for not wasting time. Well, you can easily do that using <a class="el" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e" title="adds a new function in the test list ">kct_addTestImproved(someTest,false)</a>:</p>
<div class="fragment"><div class="line"><a class="code" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e">kct_addTestImproved</a>(test51,<span class="keyword">true</span>);</div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e">kct_addTestImproved</a>(test52,<span class="keyword">true</span>);</div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e">kct_addTestImproved</a>(test53,<span class="keyword">false</span>);</div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e">kct_addTestImproved</a>(test54,<span class="keyword">true</span>);</div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8b21af1302fae84b59f07b2b8964a64e">kct_addTestImproved</a>(test55,<span class="keyword">true</span>);</div>
</div><!-- fragment --><p>While the first parameter is again the test function the second parameter indicates whether or not the computer should actually run the test: when you want to reexecute the function you can change "false" to "true".</p>
<p>Sure, you can just comment out the particular "kct_addTest(test53);" line, but the header let you also handle the skip in this way.</p>
<p>Some notes about how skipping tests influence the result outcomes:</p><ol type="1">
<li>the ratio successful tests/Number of tests does count the skipped tests;</li>
<li>the ratio failed tests/Number of tests does count the skipped tests;</li>
<li>the percentage of successful tests does not count skipped tests;</li>
<li>the percentage of failed tests does not count skipped tests;</li>
</ol>
<p>This means that the percentage of successful tests <b>must always be 100%</b>: if it isn't, then some tests aren't working. On the other hand the percentage of failed tests <b>must always be 0%</b>.</p>
<h1><a class="anchor" id="section07"></a>
Deeper understanding of KoldarCTester.h</h1>
<p>As we have said before, KoldarCTester basically creates a test list and loop over it.</p>
<div align="center">
<img src="dot_inline_dotgraph_1.png" alt="dot_inline_dotgraph_1.png" border="0" usemap="#dot_inline_dotgraph_1.map"/>
<map name="dot_inline_dotgraph_1.map" id="dot_inline_dotgraph_1.map"></map>
</div>
<p>Firstly the list (which in the header has type <a class="el" href="structTestList.html" title="Represents the entire list of test functions. ">TestList</a>) is NULL. When someone use the function <a class="el" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57" title="adds a new function in the test list ">kct_addTest()</a> or a similar function, the header automatically initialize the metadata of the list (stored in a <a class="el" href="structTestList.html" title="Represents the entire list of test functions. ">TestList</a> structure). This struct has some metadata like: </p><ul>
<li>head (basilar if you want to loop over the list!); </li>
<li>tail (used to speed up the process of appending test at the tail of the list); </li>
<li>size;</li>
</ul>
<p>When someone use <a class="el" href="KoldarCTester_8h.html#a5e05020cd2cbf6ef54e4abb4c5d3ca57" title="adds a new function in the test list ">kct_addTest()</a> (or a similar function) the header automatically initialize a new element of <a class="el" href="structTestListElement.html" title="Defines a single element of the list. ">TestListElement</a> containing a pointer of the test functions (it also contains other small metadata). The newly created struct is then append at the tail of the list. Some of the metadata stored in a <a class="el" href="structTestListElement.html" title="Defines a single element of the list. ">TestListElement</a> is: </p><ul>
<li>the test function; </li>
<li>result (the outcome of this test);</li>
</ul>
<p>The process continue over and over again until the main call kct_runAllTest(): when it happens, the program will loop through the TestListElements in the list (starting from the head one); for each of them the header will run the test function and will update some of the metadata, including the field result: this result will be important at the end of all tests, when the header has to generate statistics (like the number of test failures).</p>
<p>To allow such compact APIs, Koldar C Tester uses 2 variables: </p><ul>
<li>a default <a class="el" href="structTestList.html" title="Represents the entire list of test functions. ">TestList</a> object which is used by every function in the header as default <a class="el" href="structTestList.html" title="Represents the entire list of test functions. ">TestList</a>: in this way there's no need for the developer to manually create and initialize such list; </li>
<li>a variable currentTest: while the program iterate through out all the list element, every <a class="el" href="structTestListElement.html" title="Defines a single element of the list. ">TestListElement</a> is stored in a temporary variable. In this way the program can exactly know what <a class="el" href="structTestListElement.html" title="Defines a single element of the list. ">TestListElement</a> it is handling;</li>
</ul>
<h1><a class="anchor" id="section09"></a>
Name Conventions</h1>
<p>Here I'll focus on the private part of the header.</p>
<p>First of all, all private macro/function/types/variables starts with the prefix "pkctX_" (it means Private Koldar C Tester). X is actually a character, whose value depends on what exactly is the private resource; for example:</p><ol type="1">
<li>if it is a macro, X will be m (pkctm_&lt;name of the macro&gt;);</li>
<li>if it is a type, X will be t (pcktt_&lt;name of the type&gt;);</li>
<li>if it is a variable, X will be v (pcktv_&lt;name of the variable);</li>
</ol>
<p>Keep this in mind while you are looking inside this header. The second name convention you have to keep in mind is the all caps naming: all caps naming are all the private macros the header uses to implements its objectives; viceversa lowercase macros are all the macro representing a easy interface for the user. For example "PKCTM_INITTESTLIST()" macro creates a test element inside the list. Its user-interface is "kct_addTest()" which handles all the parameter not strictly necessary. There only an exception for this rule: the control macro. Control macros are alwasy all caps.</p>
<h1><a class="anchor" id="section10"></a>
Writing you own assertions</h1>
<p>When writing assertion keep in mind this tips:</p><ol type="1">
<li>always group the code of an assertion between "{ }": in this way the scope of all the variable you create inside the assertion will not go outside the assertion itself; For example, this assertion is coded right: <div class="fragment"><div class="line"><span class="comment">//this define is still wrong! see point 2</span></div>
<div class="line"><span class="preprocessor">#define kct_assertYouAreAPro(you,i) { \</span></div>
<div class="line"><span class="preprocessor">        printf(&quot;%d --&gt; %s &lt;-- %d\n&quot;,i,you,i); \</span></div>
<div class="line"><span class="preprocessor">        kct_ok(); \</span></div>
<div class="line"><span class="preprocessor">}</span></div>
</div><!-- fragment --></li>
<li>always create a temporary variable in macro definition: in this way if the user insert a costly-computational function as parameter (or worse a random function), the macro will not behave weird. For example this assertion is coded wrong: <div class="fragment"><div class="line"><span class="preprocessor">     #define kct_assertYouAreAPro(you,i) { \</span></div>
<div class="line"><span class="preprocessor">     printf(&quot;%d --&gt; %s &lt;-- %d\n&quot;,i,you,i); \</span></div>
<div class="line"><span class="preprocessor">     kct_ok(); \</span></div>
<div class="line"><span class="preprocessor">}</span></div>
</div><!-- fragment --> What if i is "rand()%1000"? the substitution would be <code>"563 --&gt; Koldar &lt;-- 875"</code>. And if i is a very complicate function the assertion would computate it twice! To avoid this you can add temporary variables: <div class="fragment"><div class="line"><span class="comment">//this define is still wrong! see point 3</span></div>
<div class="line"><span class="preprocessor">     #define kct_assertYouAreAPro(you,i) { \</span></div>
<div class="line"><span class="preprocessor">             int i2=(i);</span></div>
<div class="line">     <span class="keywordtype">char</span>* you2=(you);</div>
<div class="line">     printf(<span class="stringliteral">&quot;%s is over %d!\n&quot;</span>,you2,i2); <a class="code" href="KoldarCTester_8h.html#a8497b72e092de90ddde2ebf2aad987ca">\</a></div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8497b72e092de90ddde2ebf2aad987ca">     kct_ok</a>(); \</div>
<div class="line">}</div>
</div><!-- fragment --></li>
<li>always use non standard variable names: Because of the way macros work you have to declare the temporary variables with weird names; in this way you can avoid duplicating vairable and so avoid shadowing. For example this is wrong: <div class="fragment"><div class="line"><span class="preprocessor">     #define kct_assertYouAreAPro(you,i) { \</span></div>
<div class="line"><span class="preprocessor">             int i2=(i);</span></div>
<div class="line">     <span class="keywordtype">char</span>* you2=(you);</div>
<div class="line">     printf(<span class="stringliteral">&quot;%s is over %d!\n&quot;</span>,you2,i2); <a class="code" href="KoldarCTester_8h.html#a8497b72e092de90ddde2ebf2aad987ca">\</a></div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8497b72e092de90ddde2ebf2aad987ca">     kct_ok</a>(); \</div>
<div class="line">}</div>
</div><!-- fragment --> What if the tester has already declared a variable called i2? Those 2 variable might confuse the compiler (shadowing). To avoid this use the prefix discussed at the beginning of <a class="el" href="index.html#section09">Name Conventions</a> : in this case "pkctv_": <div class="fragment"><div class="line"><span class="preprocessor">     #define kct_assertYouAreAPro(you,i) { \</span></div>
<div class="line"><span class="preprocessor">             int pkctv_i2=(i);</span></div>
<div class="line">     <span class="keywordtype">char</span>* pkctv_you2=(you);</div>
<div class="line">     printf(<span class="stringliteral">&quot;%s is over %d!\n&quot;</span>,pkctv_you2,pkctv_i2); <a class="code" href="KoldarCTester_8h.html#a8497b72e092de90ddde2ebf2aad987ca">\</a></div>
<div class="line"><a class="code" href="KoldarCTester_8h.html#a8497b72e092de90ddde2ebf2aad987ca">     kct_ok</a>(); \</div>
<div class="line">}</div>
</div><!-- fragment --> It will not avoid the shadowing but it will reduce its occurence. </li>
</ol>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Sat Aug 23 2014 20:58:22 for KoldarCTester by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.8 </li>
  </ul>
</div>
</body>
</html>
